<template>
  <!-- 建设验收审核 -->
  <div>
    <!-- 搜索 -->
    <commonSearch  @filterChange="changeHandle"  @onCollapse="collapseHandle" />
    <!-- table -->
    <FilterTable
      ref="table"
      :columns="columns"
      :isSelectColumn="isSelectColumn"
      :fetchapi="fetchParams"
      :params="flterValue"
      :datakey="'records'"
      :onColumnsChange="columns => this.columns = columns"
    >
    <template slot="controls">
          <el-button size="small" type="primary" icon="el-icon-plus" @click="editHandle(null,'add')">新增</el-button>
     </template>
    </FilterTable>
     <Drawer
      :visible.sync="visibleDrawer"
      title="经销商信息审核"
      :width="1050"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
     >
      <dealerForm v-model="initData"  @close="editClose" />
    </Drawer>
  </div>
</template>
<script>
import commonSearch from '../commonSearch/index'
import dealerForm from '../dealerForm/index'
import { dictionary } from '@/utils/dictMixin';
export default {
  name:'originInfoReview',
  mixins: [dictionary],
  components: {
    commonSearch,
    dealerForm
  },
  data() {
    return {
      isSelectColumn: false,
      visibleDrawer: false,
      initData: {},
      flterValue: {}, //参数
      columns: this.creatHeader(),
      fetchParams: null //ipa 接口
    };
  },
  mounted() {
    this.BaseTable = this.$refs.table.$refs.pageTable;
  },
  methods: {
    //搜索获取数据
    changeHandle(val) {
      this.flterValue = val;
      console.log(val);
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '操作',
          dataIndex: 'column-action',
          width: 100,
          fixed: 'left',
          render: (props, h) => {
            return (
              <div>
                <el-button size="mini" type="text" onClick={() => this.editHandle(props.row,'edit')}>
                  编辑
                </el-button>
              </div>
            );
          }
        },

        { title: '状态', dataIndex: 'field0', sorter: true },
        { title: '公司全称', dataIndex: 'field2', sorter: true },
        { title: '临时代码', dataIndex: 'field3', sorter: true },
        { title: '经销商代码', dataIndex: 'field04', sorter: true },
        { title: '经销商简称', dataIndex: 'field4', sorter: true },
        {
          title: '经销商类型',
          dataIndex: 'field5',
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }
        },
        {
          title: '经销商类型',
          dataIndex: '店面级别',
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }
        },
        {
          title: '展厅级别',
          dataIndex: 'field6',
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }
        },
        {
          title: '售后级别',
          dataIndex: 'field7',
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }
        },
        { title: '事业部', dataIndex: 'field11', sorter: true },
        { title: '办事处', dataIndex: 'field12', sorter: true },
        { title: '省份', dataIndex: 'field13', sorter: true },
        { title: '城市', dataIndex: 'field14', sorter: true },
        { title: '县区', dataIndex: 'field15', sorter: true },
        { title: '系统管理员', dataIndex: 'field16', sorter: true },
        { title: '管理员电话', dataIndex: 'field17', sorter: true },
        { title: '保证金金额', dataIndex: 'field18', numberFormat: true, sorter: true },
        {
          title: '启用标记',
          dataIndex: 'field19',
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }
        },
        {
          title: '经营状态',
          dataIndex: 'field20',
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }
        },
        {
          title: '是否启用中央补贴',
          dataIndex: 'field21',
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }
        },

        {
          title: '是否启用地方补贴',
          dataIndex: 'field22',
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }
        },
        {
          title: '开票是否包含地方补贴',
          dataIndex: 'field221',
          sorter: true,
          render: props => {
            //编码转汉字
            return <span>{this.createDictText(props.row.basedataRelateId, '1611')}</span>;
          }
        }
      ];
    },
    editHandle(row, type) {
      //逻辑自己写
      this.initData = {
        type: 'edit', //add/edit/show
        id: 1001
      }; //行id
      this.visibleDrawer = true;
    },
    editClose() {
      this.visibleDrawer = false;
      if (type === 'refresh') {
        // 重新加载
        this.fetchParams = { ...this.fetchParams };
      }
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable.EXECUTE_RESET_HEIGHT();
      });
    }
  }
};
</script>

<style lang="less" scoped>
</style>
